﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using SimpleFMMatrix.DataStructures;

namespace SimpleFMMatrix.ViewModel
{
    public class OperatorVM : DependencyObject
    {
        public EnvelopeVM EnvelopeVM { get; private set; }
        public ValuedDependencyObject Ratio { get; private set; }
        public ValuedDependencyObject Offset { get; private set; }



        public string OperatorName
        {
            get { return (string)GetValue(OperatorNameProperty); }
            set { SetValue(OperatorNameProperty, value); }
        }

        public static readonly DependencyProperty OperatorNameProperty =
            DependencyProperty.Register("OperatorName", typeof(string), typeof(OperatorVM),
                new PropertyMetadata(""));



        internal OperatorVM(Operator e, string name, Action updatePreview)
        {
            EnvelopeVM = new EnvelopeVM(e.Envelope);

            OperatorName = name;

            Ratio = new ValuedDependencyObject(e.Ratio, (o, n) =>
            {
                e.Ratio = n;
                updatePreview();
            });

            Offset = new ValuedDependencyObject(e.Offset, (o, n) =>
            {
                e.Offset = n;
                updatePreview();
            });
        }
    }
}
